package com.wzh.oj.judge;

import com.wzh.oj.judge.codesandbox.model.JudgeContext;
import com.wzh.oj.judge.codesandbox.model.JudgeInfo;
import com.wzh.oj.judge.strategy.DefaultJudgeStrategy;
import com.wzh.oj.judge.strategy.JavaLanguageJudgeStrategy;
import com.wzh.oj.model.entity.QuestionSubmit;
import org.springframework.stereotype.Service;

/**
 * @author wzh
 * 判题管理，简化调用
 */
@Service
public class JudgeManage {

    public JudgeInfo doJudge(JudgeContext judgeContext){
        QuestionSubmit questionSubmit = judgeContext.getQuestionSubmit();
        String language = questionSubmit.getLanguage();
        if ("java".equals(language)){
            return new JavaLanguageJudgeStrategy().doJudge(judgeContext);
        }else {
            return new DefaultJudgeStrategy().doJudge(judgeContext);
        }
    }
}
